package katris.selenium.tests.util;

import katris.selenium.tests.webdriver.WebDriverFactory;

import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;

public class ApplicationManager {
	
    protected WebDriver driver;
    
	protected String gridHubUrl;

	public String baseUrl;
	
	private String movieUrl;

	protected Browser browser;
    
     public ApplicationManager(){
    	
		baseUrl = PropertyLoader.loadProperty("site.url");
		movieUrl = PropertyLoader.loadProperty("movie.url");
		gridHubUrl = PropertyLoader.loadProperty("grid2.hub");

		browser = new Browser();
		browser.setName(PropertyLoader.loadProperty("browser.name"));
		browser.setVersion(PropertyLoader.loadProperty("browser.version"));
		browser.setPlatform(PropertyLoader.loadProperty("browser.platform"));

		String username = PropertyLoader.loadProperty("user.username");
		String password = PropertyLoader.loadProperty("user.password");
		
		driver = WebDriverFactory.getInstance(gridHubUrl, browser, username,
				password);
    }
    
    public WebDriver getWebDriver() {
        return driver;
    }
    
    public String getMovieUrl() {
        return movieUrl;
    }

    public void stop() {
        if (driver != null) {
            driver.quit();
        }
    }
    
    
    
}
